package com.atguigu.srb.common.exception;

import com.atguigu.srb.common.result.ResponseEnum;
import lombok.extern.slf4j.Slf4j;

/**
 * ClassName: Assert
 * Package: com.atguigu.srb.common.exception
 * Description:
 *
 * @Author 王晓龙
 * @Create 2023/3/27 6:55
 * @Version 1.0
 */
@Slf4j
public class Assert {
    public static void notNull(Object o, ResponseEnum responseEnum){
        if (o == null){
            log.info("obj is null ...");
            throw new SrbException(responseEnum);
        }
    }

    public static void assertTrue(boolean flag, ResponseEnum responseEnum){
        if (!flag){
            throw new SrbException(responseEnum);
        }
    }

    public static void assertNotTrue(boolean flag, ResponseEnum responseEnum){
        if (flag){
            throw new SrbException(responseEnum);
        }
    }
}
